﻿$(function () {
//首页banner可以带视频效果
$(window).resize();
var mySwiper = new Swiper('.banner .swiper-container',{
    pagination : '.banner .swiper-pagination',
    //grabCursor: true,
    paginationClickable: true,
    prevButton:'.banner .swiper-button-prev',
    nextButton:'.banner .swiper-button-next',
    autoplay:5000,
    speed:1000,
    loop: true,
    autoplayDisableOnInteraction : false,
    onInit: function(swiper){
        swiperAnimateCache(swiper);
        swiperAnimate(swiper); 
    }, 
    onSlideChangeEnd: function(swiper){
        swiperAnimate(swiper);
        var _this = $('.banner .swiper-slide').eq(swiper.activeIndex);
        if($(window).width()>767){
            videoSelect(_this);
        }
    }
})
if($("html").hasClass("lt10")){
    var test2 = setInterval(function () {
        mySwiper.slideNext();
    }, 15000);

    $(".banner").hover(function(){
        clearInterval(test2);
    },function(){
        test2 = setInterval(function () {
            mySwiper.slideNext();
        }, 5000);
    })
}

if($(window).width()>767){
    videoSelect($('.banner .swiper-slide.swiper-slide-active'));
}

function videoSelect(_this){
    var flag = true;
    var cc = _this.hasClass('ban_video');
    if(cc){
        mySwiper.stopAutoplay();
        var videos =
            '<video src="'+ _this.data('video') +'" autoplay="autoplay" muted class="vv" style="display:none;"></video>';
        _this.append(videos);
        var aaa = setInterval(function(){
            if(!isNaN($(".vv").get(0).duration)&&flag){
                clearInterval(aaa);
                flag=false;
                setTimeout(function(){
                    _this.find('video').css("display","block");
                },500)
            }
        },10);
        _this.find('video').bind('ended',function () {
            mySwiper.slideNext();
            mySwiper.startAutoplay();
        });
    }else{
        $('.vv').remove();
    }
}
//首页banner end

    $(".selects .pub_select input").click(function(){
        $(this).siblings(".option").slideToggle();
        //$(this).siblings(".arrow").toggleClass("on");
        $(this).parents(".pub_select").siblings().find(".option").slideUp(200);
        //$(".select-box").removeClass("open");
    })

   



})